{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "e819a770-b98b-4317-9e4f-f1b46480e28a",
   "metadata": {},
   "source": [
    "# 函数与文件"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a0bd2437-994d-488f-a943-a157752f1aca",
   "metadata": {},
   "source": [
    "## 函数\n",
    "\n",
    "画布设置t.make_turtle(animate=True, delay=0.02, width=400, height=400)\n",
    "\n",
    "(五角星 pentagram)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "42cba727-6400-4f47-909e-ff0fb752c5bf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<svg width=\"400\" height=\"400\" style=\"fill:none; stroke-linecap:round;\">\n",
       "    <rect width=\"100%\" height=\"100%\" fill=\"#F3F3F7\" />\n",
       "\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 200,200\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 100,100 150,100 150,70 100,70 100,100\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 300,300 350,300 350,270 300,270 300,300\" />'\n",
       "\n",
       "<g transform=\"rotate(-90.0,300.0,300.0) translate(300.0, 300.0)\">\n",
       "    <circle stroke=\"#63A375\" stroke-width=\"2\" fill=\"transparent\" r=\"5.5\" cx=\"0\" cy=\"0\"/>\n",
       "    <polygon points=\"0,12 2,9 -2,9\" style=\"fill:#63A375;stroke:#63A375;stroke-width:2\"/>\n",
       "</g>\n",
       "\n",
       "</svg>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import jupyturtle as t\n",
    "\n",
    "t.make_turtle(animate=True, delay=0.02, width=400, height=400)\n",
    "\n",
    "def rectangle(x,y,width,height):\n",
    "    t.jump_to(x,y)\n",
    "    for i in range(4):\n",
    "        if i==0 or i==2:\n",
    "            t.fd(width)\n",
    "        else:\n",
    "            t.fd(height)\n",
    "        t.lt(90)\n",
    "\n",
    "rectangle(x=100,y=100,width=50,height=30)\n",
    "rectangle(x=300,y=300,width=50,height=30)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "e5b6802c-157c-4f36-87df-721a3cfce850",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<svg width=\"200\" height=\"200\" style=\"fill:none; stroke-linecap:round;\">\n",
       "    <rect width=\"100%\" height=\"100%\" fill=\"#F3F3F7\" />\n",
       "\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 100,100\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 100,100 150,100 109.5,129.4 125,81.8 140.5,129.4 100,100\" />'\n",
       "\n",
       "<g transform=\"rotate(-90.0,100.0,100.0) translate(100.0, 100.0)\">\n",
       "    <circle stroke=\"#63A375\" stroke-width=\"2\" fill=\"transparent\" r=\"5.5\" cx=\"0\" cy=\"0\"/>\n",
       "    <polygon points=\"0,12 2,9 -2,9\" style=\"fill:#63A375;stroke:#63A375;stroke-width:2\"/>\n",
       "</g>\n",
       "\n",
       "</svg>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#五角星\n",
    "\n",
    "import jupyturtle as t\n",
    "\n",
    "t.make_turtle(animate=True, delay=0.02, width=200, height=200)\n",
    "\n",
    "def rectangle(x,y,width):\n",
    "    t.jump_to(x,y)\n",
    "    for i in range(5):\n",
    "        t.fd(width)\n",
    "        t.right(144)\n",
    "\n",
    "rectangle(x=100,y=100,width=50)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "32061fe1-ceca-45a2-a5d9-50f622449b96",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.4999999994818579\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "print(math.sin(30/180.*3.14159265))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "498f622f-5e1c-4933-a2f7-208f5caa76cd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<svg width=\"400\" height=\"400\" style=\"fill:none; stroke-linecap:round;\">\n",
       "    <rect width=\"100%\" height=\"100%\" fill=\"#F3F3F7\" />\n",
       "\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 200,200\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 54.9,119.1 245.1,119.1 91.2,230.9 150,50 208.8,230.9 54.9,119.1\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<g transform=\"rotate(-90.0,150,150) translate(150, 150)\">\n",
       "    <circle stroke=\"#63A375\" stroke-width=\"2\" fill=\"transparent\" r=\"5.5\" cx=\"0\" cy=\"0\"/>\n",
       "    <polygon points=\"0,12 2,9 -2,9\" style=\"fill:#63A375;stroke:#63A375;stroke-width:2\"/>\n",
       "</g>\n",
       "\n",
       "</svg>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import jupyturtle as t\n",
    "import math\n",
    "\n",
    "t.make_turtle(animate=True, delay=0.02, width=400, height=400)\n",
    "\n",
    "def pentagram(x,y,r):\n",
    "    t.jump_to(x-r*math.cos(18/180*math.pi),y-r*math.sin(18/180*math.pi))\n",
    "    for i in range(5):\n",
    "        t.fd(2*r*math.cos(18/180*math.pi))\n",
    "        t.right(144)\n",
    "    t.jump_to(x,y)\n",
    "pentagram(150,150,100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "2564eb02-c44f-4d7a-a15c-83b82f5cbdc5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<svg width=\"400\" height=\"400\" style=\"fill:none; stroke-linecap:round;\">\n",
       "    <rect width=\"100%\" height=\"100%\" fill=\"#F3F3F7\" />\n",
       "\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 200,200\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 54.9,119.1 245.1,119.1 91.2,230.9 150,50 208.8,230.9 54.9,119.1\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150 150,150 150,150 150,150 150,150 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 149,149.7 151,149.7 149.4,150.8 150,149 150.6,150.8 149,149.7\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 148.1,149.4 151.9,149.4 148.8,151.6 150,148 151.2,151.6 148.1,149.4\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 147.1,149.1 152.9,149.1 148.2,152.4 150,147 151.8,152.4 147.1,149.1\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 146.2,148.8 153.8,148.8 147.6,153.2 150,146 152.4,153.2 146.2,148.8\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 145.2,148.5 154.8,148.5 147.1,154 150,145 152.9,154 145.2,148.5\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 144.3,148.1 155.7,148.1 146.5,154.9 150,144 153.5,154.9 144.3,148.1\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 143.3,147.8 156.7,147.8 145.9,155.7 150,143 154.1,155.7 143.3,147.8\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 142.4,147.5 157.6,147.5 145.3,156.5 150,142 154.7,156.5 142.4,147.5\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 141.4,147.2 158.6,147.2 144.7,157.3 150,141 155.3,157.3 141.4,147.2\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 140.5,146.9 159.5,146.9 144.1,158.1 150,140 155.9,158.1 140.5,146.9\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 139.5,146.6 160.5,146.6 143.5,158.9 150,139 156.5,158.9 139.5,146.6\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 138.6,146.3 161.4,146.3 142.9,159.7 150,138 157.1,159.7 138.6,146.3\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 137.6,146 162.4,146 142.4,160.5 150,137 157.6,160.5 137.6,146\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 136.7,145.7 163.3,145.7 141.8,161.3 150,136 158.2,161.3 136.7,145.7\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 135.7,145.4 164.3,145.4 141.2,162.1 150,135 158.8,162.1 135.7,145.4\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 134.8,145.1 165.2,145.1 140.6,162.9 150,134 159.4,162.9 134.8,145.1\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 133.8,144.7 166.2,144.7 140,163.8 150,133 160,163.8 133.8,144.7\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 132.9,144.4 167.1,144.4 139.4,164.6 150,132 160.6,164.6 132.9,144.4\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 131.9,144.1 168.1,144.1 138.8,165.4 150,131 161.2,165.4 131.9,144.1\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 131,143.8 169,143.8 138.2,166.2 150,130 161.8,166.2 131,143.8\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 130,143.5 170,143.5 137.7,167 150,129 162.3,167 130,143.5\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 129.1,143.2 170.9,143.2 137.1,167.8 150,128 162.9,167.8 129.1,143.2\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 128.1,142.9 171.9,142.9 136.5,168.6 150,127 163.5,168.6 128.1,142.9\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 127.2,142.6 172.8,142.6 135.9,169.4 150,126 164.1,169.4 127.2,142.6\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 126.2,142.3 173.8,142.3 135.3,170.2 150,125 164.7,170.2 126.2,142.3\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 125.3,142 174.7,142 134.7,171 150,124 165.3,171 125.3,142\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 124.3,141.7 175.7,141.7 134.1,171.8 150,123 165.9,171.8 124.3,141.7\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 123.4,141.3 176.6,141.3 133.5,172.7 150,122 166.5,172.7 123.4,141.3\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 122.4,141 177.6,141 133,173.5 150,121 167,173.5 122.4,141\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 121.5,140.7 178.5,140.7 132.4,174.3 150,120 167.6,174.3 121.5,140.7\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 120.5,140.4 179.5,140.4 131.8,175.1 150,119 168.2,175.1 120.5,140.4\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 119.6,140.1 180.4,140.1 131.2,175.9 150,118 168.8,175.9 119.6,140.1\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 118.6,139.8 181.4,139.8 130.6,176.7 150,117 169.4,176.7 118.6,139.8\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 117.7,139.5 182.3,139.5 130,177.5 150,116 170,177.5 117.7,139.5\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 116.7,139.2 183.3,139.2 129.4,178.3 150,115 170.6,178.3 116.7,139.2\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 115.8,138.9 184.2,138.9 128.8,179.1 150,114 171.2,179.1 115.8,138.9\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 114.8,138.6 185.2,138.6 128.3,179.9 150,113 171.7,179.9 114.8,138.6\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 113.9,138.3 186.1,138.3 127.7,180.7 150,112 172.3,180.7 113.9,138.3\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 112.9,137.9 187.1,137.9 127.1,181.6 150,111 172.9,181.6 112.9,137.9\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 112,137.6 188,137.6 126.5,182.4 150,110 173.5,182.4 112,137.6\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 111,137.3 189,137.3 125.9,183.2 150,109 174.1,183.2 111,137.3\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 110.1,137 189.9,137 125.3,184 150,108 174.7,184 110.1,137\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 109.1,136.7 190.9,136.7 124.7,184.8 150,107 175.3,184.8 109.1,136.7\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 108.2,136.4 191.8,136.4 124.1,185.6 150,106 175.9,185.6 108.2,136.4\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 107.2,136.1 192.8,136.1 123.5,186.4 150,105 176.5,186.4 107.2,136.1\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 106.3,135.8 193.7,135.8 123,187.2 150,104 177,187.2 106.3,135.8\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 105.3,135.5 194.7,135.5 122.4,188 150,103 177.6,188 105.3,135.5\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 104.3,135.2 195.7,135.2 121.8,188.8 150,102 178.2,188.8 104.3,135.2\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 103.4,134.9 196.6,134.9 121.2,189.6 150,101 178.8,189.6 103.4,134.9\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 102.4,134.5 197.6,134.5 120.6,190.5 150,100 179.4,190.5 102.4,134.5\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 101.5,134.2 198.5,134.2 120,191.3 150,99 180,191.3 101.5,134.2\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 100.5,133.9 199.5,133.9 119.4,192.1 150,98 180.6,192.1 100.5,133.9\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 99.6,133.6 200.4,133.6 118.8,192.9 150,97 181.2,192.9 99.6,133.6\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 98.6,133.3 201.4,133.3 118.3,193.7 150,96 181.7,193.7 98.6,133.3\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 97.7,133 202.3,133 117.7,194.5 150,95 182.3,194.5 97.7,133\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 96.7,132.7 203.3,132.7 117.1,195.3 150,94 182.9,195.3 96.7,132.7\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 95.8,132.4 204.2,132.4 116.5,196.1 150,93 183.5,196.1 95.8,132.4\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 94.8,132.1 205.2,132.1 115.9,196.9 150,92 184.1,196.9 94.8,132.1\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 93.9,131.8 206.1,131.8 115.3,197.7 150,91 184.7,197.7 93.9,131.8\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 92.9,131.5 207.1,131.5 114.7,198.5 150,90 185.3,198.5 92.9,131.5\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 92,131.1 208,131.1 114.1,199.4 150,89 185.9,199.4 92,131.1\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 91,130.8 209,130.8 113.6,200.2 150,88 186.4,200.2 91,130.8\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 90.1,130.5 209.9,130.5 113,201 150,87 187,201 90.1,130.5\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 89.1,130.2 210.9,130.2 112.4,201.8 150,86 187.6,201.8 89.1,130.2\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 88.2,129.9 211.8,129.9 111.8,202.6 150,85 188.2,202.6 88.2,129.9\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 87.2,129.6 212.8,129.6 111.2,203.4 150,84 188.8,203.4 87.2,129.6\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 86.3,129.3 213.7,129.3 110.6,204.2 150,83 189.4,204.2 86.3,129.3\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 85.3,129 214.7,129 110,205 150,82 190,205 85.3,129\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 84.4,128.7 215.6,128.7 109.4,205.8 150,81 190.6,205.8 84.4,128.7\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 83.4,128.4 216.6,128.4 108.9,206.6 150,80 191.1,206.6 83.4,128.4\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 82.5,128.1 217.5,128.1 108.3,207.4 150,79 191.7,207.4 82.5,128.1\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 81.5,127.8 218.5,127.8 107.7,208.2 150,78 192.3,208.2 81.5,127.8\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 80.6,127.4 219.4,127.4 107.1,209.1 150,77 192.9,209.1 80.6,127.4\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 79.6,127.1 220.4,127.1 106.5,209.9 150,76 193.5,209.9 79.6,127.1\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 78.7,126.8 221.3,126.8 105.9,210.7 150,75 194.1,210.7 78.7,126.8\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 77.7,126.5 222.3,126.5 105.3,211.5 150,74 194.7,211.5 77.7,126.5\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 76.8,126.2 223.2,126.2 104.7,212.3 150,73 195.3,212.3 76.8,126.2\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 75.8,125.9 224.2,125.9 104.2,213.1 150,72 195.8,213.1 75.8,125.9\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 74.9,125.6 225.1,125.6 103.6,213.9 150,71 196.4,213.9 74.9,125.6\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 73.9,125.3 226.1,125.3 103,214.7 150,70 197,214.7 73.9,125.3\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 73,125 227,125 102.4,215.5 150,69 197.6,215.5 73,125\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 72,124.7 228,124.7 101.8,216.3 150,68 198.2,216.3 72,124.7\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 71.1,124.4 228.9,124.4 101.2,217.1 150,67 198.8,217.1 71.1,124.4\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 70.1,124 229.9,124 100.6,218 150,66 199.4,218 70.1,124\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 69.2,123.7 230.8,123.7 100,218.8 150,65 200,218.8 69.2,123.7\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 68.2,123.4 231.8,123.4 99.5,219.6 150,64 200.5,219.6 68.2,123.4\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 67.3,123.1 232.7,123.1 98.9,220.4 150,63 201.1,220.4 67.3,123.1\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 66.3,122.8 233.7,122.8 98.3,221.2 150,62 201.7,221.2 66.3,122.8\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 65.4,122.5 234.6,122.5 97.7,222 150,61 202.3,222 65.4,122.5\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 64.4,122.2 235.6,122.2 97.1,222.8 150,60 202.9,222.8 64.4,122.2\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 63.5,121.9 236.5,121.9 96.5,223.6 150,59 203.5,223.6 63.5,121.9\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 62.5,121.6 237.5,121.6 95.9,224.4 150,58 204.1,224.4 62.5,121.6\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 61.6,121.3 238.4,121.3 95.3,225.2 150,57 204.7,225.2 61.6,121.3\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 60.6,121 239.4,121 94.7,226 150,56 205.3,226 60.6,121\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 59.6,120.6 240.4,120.6 94.2,226.9 150,55 205.8,226.9 59.6,120.6\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 58.7,120.3 241.3,120.3 93.6,227.7 150,54 206.4,227.7 58.7,120.3\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 57.7,120 242.3,120 93,228.5 150,53 207,228.5 57.7,120\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 56.8,119.7 243.2,119.7 92.4,229.3 150,52 207.6,229.3 56.8,119.7\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 55.8,119.4 244.2,119.4 91.8,230.1 150,51 208.2,230.1 55.8,119.4\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<g transform=\"rotate(-90.0,150,150) translate(150, 150)\">\n",
       "    <circle stroke=\"#63A375\" stroke-width=\"2\" fill=\"transparent\" r=\"5.5\" cx=\"0\" cy=\"0\"/>\n",
       "    <polygon points=\"0,12 2,9 -2,9\" style=\"fill:#63A375;stroke:#63A375;stroke-width:2\"/>\n",
       "</g>\n",
       "\n",
       "</svg>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import jupyturtle as t\n",
    "import math\n",
    "\n",
    "t.make_turtle(animate=True, delay=0.02, width=400, height=400)\n",
    "\n",
    "def pentagram(x,y,r):\n",
    "    t.jump_to(x-r*math.cos(18/180*math.pi),y-r*math.sin(18/180*math.pi))\n",
    "    for i in range(5):\n",
    "        t.fd(2*r*math.cos(18/180*math.pi))\n",
    "        t.right(144)\n",
    "    t.jump_to(x,y)\n",
    "pentagram(150,150,100)\n",
    "\n",
    "for i in range(100):\n",
    "    pentagram(150,150,i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "9ed00d33-9380-44b5-86db-764192bc17db",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<svg width=\"400\" height=\"400\" style=\"fill:none; stroke-linecap:round;\">\n",
       "    <rect width=\"100%\" height=\"100%\" fill=\"#F3F3F7\" />\n",
       "\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 200,200\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 54.9,119.1 245.1,119.1 91.2,230.9 150,50 208.8,230.9 54.9,119.1\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 250,150 260,150 251.9,144.1 255,153.6 258.1,144.1 250,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 236.6,200 245.3,205 241.2,195.9 239.1,205.6 246.5,199 236.6,200\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 200,236.6 205,245.3 206,235.3 199.4,242.7 209.1,240.7 200,236.6\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,250 150,260 155.9,251.9 146.4,255 155.9,258.1 150,250\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 100,236.6 95,245.3 104.1,241.2 94.4,239.1 101,246.5 100,236.6\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 63.4,200 54.7,205 64.7,206 57.3,199.4 59.3,209.1 63.4,200\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 50,150 40,150 48.1,155.9 45,146.4 41.9,155.9 50,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 63.4,100 54.7,95 58.8,104.1 60.9,94.4 53.5,101 63.4,100\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 100,63.4 95,54.7 94,64.7 100.6,57.3 90.9,59.3 100,63.4\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,50 150,40 144.1,48.1 153.6,45 144.1,41.9 150,50\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 200,63.4 205,54.7 195.9,58.8 205.6,60.9 199,53.5 200,63.4\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 236.6,100 245.3,95 235.3,94 242.7,100.6 240.7,90.9 236.6,100\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,150\" />'\n",
       "\n",
       "<g transform=\"rotate(-90.0,150.0,150.0) translate(150.0, 150.0)\">\n",
       "    <circle stroke=\"#63A375\" stroke-width=\"2\" fill=\"transparent\" r=\"5.5\" cx=\"0\" cy=\"0\"/>\n",
       "    <polygon points=\"0,12 2,9 -2,9\" style=\"fill:#63A375;stroke:#63A375;stroke-width:2\"/>\n",
       "</g>\n",
       "\n",
       "</svg>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import jupyturtle as t\n",
    "import math\n",
    "\n",
    "t.make_turtle(animate=True, delay=0.02, width=400, height=400)\n",
    "\n",
    "def pentagram(x,y,r):\n",
    "    t.jump_to(x-r*math.cos(18/180*math.pi),y-r*math.sin(18/180*math.pi))\n",
    "    for i in range(5):\n",
    "        t.fd(2*r*math.cos(18/180*math.pi))\n",
    "        t.right(144)\n",
    "    t.jump_to(x,y)\n",
    "pentagram(150,150,100)\n",
    "\n",
    "def pentagram(a,b):\n",
    "    for i in range(5):\n",
    "        t.fd(a)\n",
    "        t.lt(b)\n",
    "\n",
    "for i in range(12):\n",
    "    t.pen_up()\n",
    "    t.fd(100)\n",
    "    t.pen_down()\n",
    "    pentagram(10,144)\n",
    "    t.pen_up()\n",
    "    t.back(100)\n",
    "    t.pen_down()\n",
    "    t.right(30)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "9a42be66-86ab-49d0-993b-b1bfd5990555",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<svg width=\"400\" height=\"400\" style=\"fill:none; stroke-linecap:round;\">\n",
       "    <rect width=\"100%\" height=\"100%\" fill=\"#F3F3F7\" />\n",
       "\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 200,200\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 300,200 310,200 301.9,194.1 305,203.6 308.1,194.1 300,200\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 200,200\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 286.6,250 295.3,255 291.2,245.9 289.1,255.6 296.5,249 286.6,250\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 200,200\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 250,286.6 255,295.3 256,285.3 249.4,292.7 259.1,290.7 250,286.6\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 200,200\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 200,300 200,310 205.9,301.9 196.4,305 205.9,308.1 200,300\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 200,200\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,286.6 145,295.3 154.1,291.2 144.4,289.1 151,296.5 150,286.6\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 200,200\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 113.4,250 104.7,255 114.7,256 107.3,249.4 109.3,259.1 113.4,250\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 200,200\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 100,200 90,200 98.1,205.9 95,196.4 91.9,205.9 100,200\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 200,200\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 113.4,150 104.7,145 108.8,154.1 110.9,144.4 103.5,151 113.4,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 200,200\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 150,113.4 145,104.7 144,114.7 150.6,107.3 140.9,109.3 150,113.4\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 200,200\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 200,100 200,90 194.1,98.1 203.6,95 194.1,91.9 200,100\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 200,200\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 250,113.4 255,104.7 245.9,108.8 255.6,110.9 249,103.5 250,113.4\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 200,200\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 286.6,150 295.3,145 285.3,144 292.7,150.6 290.7,140.9 286.6,150\" />'\n",
       "\n",
       "<path stroke=\"#663399\" stroke-width=\"2\" d=\"M 200,200\" />'\n",
       "\n",
       "<g transform=\"rotate(-90.0,200.0,200.0) translate(200.0, 200.0)\">\n",
       "    <circle stroke=\"#63A375\" stroke-width=\"2\" fill=\"transparent\" r=\"5.5\" cx=\"0\" cy=\"0\"/>\n",
       "    <polygon points=\"0,12 2,9 -2,9\" style=\"fill:#63A375;stroke:#63A375;stroke-width:2\"/>\n",
       "</g>\n",
       "\n",
       "</svg>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "ename": "TypeError",
     "evalue": "pentagram() takes 2 positional arguments but 3 were given",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[16], line 22\u001b[0m\n\u001b[0;32m     19\u001b[0m     t\u001b[38;5;241m.\u001b[39mright(\u001b[38;5;241m30\u001b[39m)\n\u001b[0;32m     21\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(\u001b[38;5;241m100\u001b[39m):\n\u001b[1;32m---> 22\u001b[0m     pentagram(\u001b[38;5;241m150\u001b[39m,\u001b[38;5;241m150\u001b[39m,i)\n",
      "\u001b[1;31mTypeError\u001b[0m: pentagram() takes 2 positional arguments but 3 were given"
     ]
    }
   ],
   "source": [
    "import jupyturtle as t\n",
    "import math\n",
    "t.make_turtle(animate=True, delay=0.02, width=400, height=400)\n",
    "\n",
    "def pentagram(a,b):\n",
    "    for i in range(5):\n",
    "        t.fd(a)\n",
    "        t.lt(b)\n",
    "\n",
    "\n",
    "for i in range(12):\n",
    "    t.pen_up()\n",
    "    t.fd(100)\n",
    "    t.pen_down()\n",
    "    pentagram(10,144)\n",
    "    t.pen_up()\n",
    "    t.back(100)\n",
    "    t.pen_down()\n",
    "    t.right(30)\n",
    "\n",
    "for i in range(100):\n",
    "    pentagram(150,150,i)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ee1693bf-e079-4c2a-a532-0c5797487089",
   "metadata": {},
   "source": [
    "## 文件（File）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "9aee9ac6-6ea1-4b3a-97ff-1868fdff5c47",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "8\n"
     ]
    }
   ],
   "source": [
    "#读文件中的内容长度\n",
    "file = open(\"test.txt\",\"r\")\n",
    "content = file.read()\n",
    "file.close()\n",
    "print(len(content))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "60696df7-afe2-46d6-aa2c-747b1810dd50",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "12345\n",
      "\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "#读文件中的内容\n",
    "file = open(\"test.txt\",\"r\")\n",
    "content = file.read()\n",
    "file.close()\n",
    "print(content)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "6e165481-6a43-4170-926a-04e66bcf8410",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "12345\n",
      "\n"
     ]
    }
   ],
   "source": [
    "file = open(\"test.txt\",\"r\")\n",
    "lines = file.readlines()\n",
    "file.close()\n",
    "print(lines[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "ff57b603-fafc-4df9-af82-6b8a89276cf6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "12345\n",
      "\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "with open(\"test.txt\",\"r\") as file:\n",
    "    content = file.read()\n",
    "print(content)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "2863b3ee-8345-4ad0-ac28-09dfb56abc0a",
   "metadata": {},
   "outputs": [
    {
     "ename": "UnicodeDecodeError",
     "evalue": "'gbk' codec can't decode byte 0x8c in position 3: illegal multibyte sequence",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mUnicodeDecodeError\u001b[0m                        Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[8], line 2\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mopen\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtest.txt\u001b[39m\u001b[38;5;124m\"\u001b[39m,\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mr\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;28;01mas\u001b[39;00m file:\n\u001b[1;32m----> 2\u001b[0m     content \u001b[38;5;241m=\u001b[39m file\u001b[38;5;241m.\u001b[39mread()\n\u001b[0;32m      3\u001b[0m \u001b[38;5;28mprint\u001b[39m(content\u001b[38;5;241m.\u001b[39msplit(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m，\u001b[39m\u001b[38;5;124m\"\u001b[39m))\n",
      "\u001b[1;31mUnicodeDecodeError\u001b[0m: 'gbk' codec can't decode byte 0x8c in position 3: illegal multibyte sequence"
     ]
    }
   ],
   "source": [
    "with open(\"test.txt\",\"r\") as file:\n",
    "    content = file.read()\n",
    "print(content.split(\"，\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "40c114c0-e9ab-4922-b20a-df26e1e95b22",
   "metadata": {},
   "outputs": [],
   "source": [
    "lines = ['Hello, World!\\n', 'Welcome to Python.\\n']\n",
    "with open('test.txt', 'a') as file:\n",
    "    file.writelines(lines)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "25c46d40-dfeb-4ba0-8029-20a742a2359a",
   "metadata": {},
   "outputs": [],
   "source": [
    "lines = ['51.112  89.928   5.058  72.565  48.786  24.335  46.888  34.525  48.900   7.826\\n',\n",
    "  '52.965  56.345  15.166  51.543   5.456  64.860  33.661  89.005  48.026   1.651\\n',\n",
    "  '24.688  22.141  59.111  42.907  93.191  21.834  67.694  44.455  31.601  12.184\\n',\n",
    "  '22.067  92.760  78.599  96.267  27.922  29.006  45.807   4.440  32.055  46.188\\n',\n",
    "  '74.569  25.721   4.845  55.636  84.524  27.614  22.400  46.689  20.525  62.931\\n',\n",
    "   '4.671  73.157  13.588  30.191  21.660  16.453  40.220  49.896   0.158  16.482\\n',\n",
    "  '67.494  49.503  33.735  34.827  78.383  63.336  69.026  90.299  84.255  71.680\\n',\n",
    "  '71.904  46.795  86.245  50.976  89.778  80.108  98.571   9.270  24.336  89.126\\n',\n",
    "  '80.074  46.039  67.132  81.424  53.039  82.561  47.027  37.958  57.282   7.202\\n',\n",
    "   '8.746  91.279  52.398  24.818  32.554  62.723   1.461  16.042  30.854  43.104\\n', ]\n",
    "with open('test.txt', 'a') as file:\n",
    "    file.writelines(lines)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "ce5d1821-d0f3-4df7-b43f-af9b05eb73cd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  69.797   2.964  74.932  81.361  45.051  76.492  73.664  13.311  61.146  81.445\n",
      "  20.749  15.062  90.612  88.499  23.001  12.310  55.895  53.680  28.274  45.255\n",
      "  86.658  99.095  65.839   3.124  65.675  15.600  85.699  63.933  16.906   3.306\n",
      "   8.926  54.176   6.669  93.487  68.875  69.353   5.167  79.353  36.692  39.615\n",
      "  65.499  55.827  71.161  70.135  96.955  10.073  96.395  45.149  87.491  46.387\n",
      "  82.659  93.302  44.692  13.758  79.227   9.364  68.516  97.867  95.600  52.020\n",
      "  15.329  84.173  93.546  20.200  96.978  62.124  31.321  44.691  99.879  27.394\n",
      "  44.517  36.272  67.748  56.899  72.018  74.990  65.965  68.722  27.437  47.118\n",
      "  37.323  98.044  97.982  41.570  48.690   8.467  83.027  11.609  61.075   5.674\n",
      "  91.181  80.370  98.960  72.679  27.522  71.712  42.324  17.293  86.717  31.425\n",
      "\n"
     ]
    },
    {
     "ename": "TypeError",
     "evalue": "write() argument must be str, not None",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[20], line 10\u001b[0m\n\u001b[0;32m      8\u001b[0m lines \u001b[38;5;241m=\u001b[39m [\u001b[38;5;28mprint\u001b[39m()]\n\u001b[0;32m      9\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mopen\u001b[39m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mtest.txt\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124ma\u001b[39m\u001b[38;5;124m'\u001b[39m) \u001b[38;5;28;01mas\u001b[39;00m file:\n\u001b[1;32m---> 10\u001b[0m     file\u001b[38;5;241m.\u001b[39mwritelines(lines)\n",
      "\u001b[1;31mTypeError\u001b[0m: write() argument must be str, not None"
     ]
    }
   ],
   "source": [
    "import random\n",
    "i = 0\n",
    "for i in range(100):\n",
    "    x = random.uniform(0,100)\n",
    "    print(\"%8.3f\" % x , end=\"\")\n",
    "    if (i+1) % 10 == 0:\n",
    "        print()\n",
    "lines = []\n",
    "with open('test.txt', 'a') as file:\n",
    "    file.writelines(lines)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "53bfa848-9b5c-4661-8435-4980d2a10587",
   "metadata": {},
   "outputs": [],
   "source": [
    "import random\n",
    "\n",
    "with open('test.txt', 'a') as file:\n",
    "    for i in range(100):\n",
    "        x = random.randint(0, 100) \n",
    "        file.write(f\"{x}\\t\") \n",
    "        if (i + 1) % 10 == 0:\n",
    "            file.write(\"\\n\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f214ebf5-1ca6-404b-afe9-29da665451bd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "12.83,14.09, 4.08, 7.38,90.39,38.60,65.71,61.27,65.03,74.61\n",
      "29.55,18.39,41.10,15.75,16.19,24.62,96.23,14.14,94.83,75.95\n",
      "82.89,74.23,82.00,23.75,44.15,22.41,89.01,68.67,86.36,13.45\n",
      "45.58,45.11,76.34,45.67,69.41,69.60,62.95,58.61, 5.82,97.85\n",
      "75.46,73.60,13.60,63.43,86.87,62.98,95.07,56.24,47.87,53.16\n",
      "93.81,26.74,49.13,59.00,53.54,17.27,30.66,16.66,28.44,91.30\n",
      "56.03,76.17,44.92,23.79,27.32,83.71,70.55,87.40,20.40,27.53\n",
      " 5.82,46.27,29.62,57.61,24.05,16.40,49.60,65.99,15.85,49.02\n",
      "22.22, 6.71,35.86,60.71,31.11, 2.84,54.93,22.05,59.78,71.95\n",
      "27.76,40.42,10.34,55.30,30.32,22.18,84.24,50.09,22.81, 2.45\n",
      "\n"
     ]
    }
   ],
   "source": [
    "import random\n",
    "\n",
    "s = ''\n",
    "for i in range(100):\n",
    "    num = random.random()*100\n",
    "    if (i+1)%10 == 0:\n",
    "        x = \"\\n\"\n",
    "    else:\n",
    "        x = \",\"\n",
    "    s = s + f\"{num:5.2f}\"+ x\n",
    "print(s)\n",
    "\n",
    "with open(\"test.txt\",\"w\") as file:\n",
    "    file.write(s)\n",
    "    file.writelines(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "2589c974-3910-41a4-be79-959b77d1eb6a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0-10: 14个数据\n",
      "10-20: 26个数据\n",
      "20-30: 34个数据\n",
      "30-40: 10个数据\n",
      "40-50: 24个数据\n",
      "50-60: 22个数据\n",
      "60-70: 22个数据\n",
      "70-80: 18个数据\n",
      "80-90: 16个数据\n",
      "90-100: 14个数据\n"
     ]
    },
    {
     "ename": "IndexError",
     "evalue": "list index out of range",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mIndexError\u001b[0m                                Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[9], line 22\u001b[0m\n\u001b[0;32m     20\u001b[0m start \u001b[38;5;241m=\u001b[39m i \u001b[38;5;241m*\u001b[39m \u001b[38;5;241m10\u001b[39m\n\u001b[0;32m     21\u001b[0m end \u001b[38;5;241m=\u001b[39m (i \u001b[38;5;241m+\u001b[39m \u001b[38;5;241m1\u001b[39m) \u001b[38;5;241m*\u001b[39m \u001b[38;5;241m10\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m i \u001b[38;5;241m<\u001b[39m \u001b[38;5;241m10\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m100\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m---> 22\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mi\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m10\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m-\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mi\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m10\u001b[39m\u001b[38;5;241m+\u001b[39m\u001b[38;5;241m10\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mcount[i]\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m个数据\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
      "\u001b[1;31mIndexError\u001b[0m: list index out of range"
     ]
    }
   ],
   "source": [
    "\n",
    "list = []\n",
    "\n",
    "with open(\"test.txt\", \"r\") as file:\n",
    "    data = file.read().replace('\\n', ',')\n",
    "    raw = data.split(',')\n",
    "    for i in range(len(raw)):\n",
    "        if raw[i]: \n",
    "            list.append(float(raw[i]))\n",
    "\n",
    "count = [0] * 10\n",
    "\n",
    "for i in range(len(list)):\n",
    "    num = list[i]\n",
    "    if 0 <= num < 100:  \n",
    "        \n",
    "        classification = int(num // 10) \n",
    "        count[classification] += 1\n",
    "\n",
    "for i in range(11):\n",
    "    start = i * 10\n",
    "    end = (i + 1) * 10 if i < 10 else '100'\n",
    "    print(f\"{i*10}-{i*10+10}: {count[i]}个数据\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "bcaadca0-940e-4d82-a46c-b8660938b479",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0-10: 14个数据\n",
      "10-20: 26个数据\n",
      "20-30: 34个数据\n",
      "30-40: 10个数据\n",
      "40-50: 24个数据\n",
      "50-60: 22个数据\n",
      "60-70: 22个数据\n",
      "70-80: 18个数据\n",
      "80-90: 16个数据\n",
      "90-100: 14个数据\n"
     ]
    }
   ],
   "source": [
    "\n",
    "list = []\n",
    "\n",
    "with open(\"test.txt\", \"r\") as file:\n",
    "    data = file.read().replace('\\n', ',')\n",
    "    raw = data.split(',')\n",
    "    for i in range(len(raw)):\n",
    "        if raw[i]: \n",
    "            list.append(float(raw[i]))\n",
    "\n",
    "count = [0] * 10\n",
    "\n",
    "for i in range(len(list)):\n",
    "    num = list[i]\n",
    "    if 0 <= num < 100:  \n",
    "        \n",
    "        classification = int(num // 10) \n",
    "        count[classification] += 1\n",
    "\n",
    "for i in range(10):\n",
    "    print(f\"{i*10}-{i*10+10}: {count[i]}个数据\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d30bac52-13a6-4138-a817-218d20b056a9",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
